﻿;_____________________________________________________________________
;---------------------------------------------------------------------
;	File: PML_Functions
;---------------------------------------------------------------------
;	Group: Overview
;
;		Contains functions in the PM App Launcher code
;
;	Group: About
;		General script file information
;
;		- *Written By:* 	Rameen Bakhtiary
;		- *Last Modified:*	11/24/2011
;_____________________________________________________________________
;---------------------------------------------------------------------





;===================================================================================================	
;	Function: error_Handle
;		Displays an error message to the user informing of a problem. Takes action necessary
;		based on parameters. Either ignores the error, warns user, or exits the program.
;	
;	Parameters:
;		error - (optional) What error occurred. Either "missing" or "com" for missing files or communication
;				issues with server
;		app - (optional) Program that failed/caused an issue or is missing
;		action - (optional) Action to take on error. EIther "ignore," "Warn" or "quit."
;			ignore will return "ignored" and continue execution. "warn" displays a warning message to
;			user with an error description, and "quit" displays the same error message, then exits the application.
;	
;	Return Value: 
;		Returns "ignored" if action = "ignore," otherwise returns 0, or empty value.
;	
;	Example: 
;		(Start code)
;			;This example would show a msgbox warning that Spec Finder wasn't found;
;			;execution would then continue
;			If ! FileExist("Include\Spec Finder\specFinder.exe"){ ; 	Missing specFinder
;				error_handle("missing", "Spec Finder")
;			return
;		(End)
;===================================================================================================
error_Handle(error="",app="",action="Warn"){

	; Don't notify user of Error
	;======================
	If (severe = "Ignore")
		Return ("Ignored")
	
	; Notify user of Error
	;=================
	Else If (severe = "Warn"){
		MsgBox, 4144, PM App Launcher, % "An Error occurred with PM App Launcher.`n`n" 			( p1 = "missing" ? (app ? app " could Not be located On your computer. You should re-Run the installer.`n`n" 			   : "An unidentified program Is missing from your computers. Try re-running the installer.`n`n") 			   : p1 = "com" ? (app ? app "could Not be downloaded from the server. Try again later Or Check your internet/network connection.`n`n" 			   : "Error occurred While trying to communicate with external app server. Try again later Or Check your network connection.`n`n") 			   : "Apparently that's All I know....`n`n" 			)																																		
	}
	; Exit app after notifying
	;====================
	If (severe="quit")
		ExitApp
}




;===================================================================================================
;	Function: splash
;		Display splash image that goes away on mouse click
;
;===================================================================================================
splash(_Txt, SPLASH_OPTIONS, _Pic=""){
	SplashImage, %_Pic%, %SPLASH_OPTIONS%, `n[Click anywhere to close this window], %_Txt%,, Century Gothic
	keywait, LButton, D
	SplashImage, off
}
		
		
		
		
		
		
		
		
		
		
		